<template scoped>
  <div class="margin-top-40">
      <ul class="photo-nav">
          <li @click="getImgList(0)">全部</li>
          <li v-for="(itm,idx) in imgCategory" :key="idx" @click="getImgList(itm.id)">{{itm.title}}</li>
      </ul>

        <router-link class="photo-list" v-for="(item,index) in imgListInfo" :key="index" :to="'/photo/photoinfo/'+item.id">
            <img :src="item.img_url" alt="">
            <div class="photo-list-info">
                <h4>{{item.title}}</h4>
                <p>{{item.zhaiyao}}</p>
            </div>
        </router-link>

  </div>
</template>
<style scoped> 
    .photo-nav{
        overflow-x: scroll;
        white-space: nowrap;
        border-bottom: solid 1px #999;
    }
    .photo-nav li{
        display: inline-block;
        padding: 10px;
    }

    .photo-list{
        position: relative;
        width: 100%;
        height: 350px;
        margin-top: 10px;
    }
    .photo-list img{
        width: 100%;
        height: 100%;
    }
    .photo-list-info{
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: rgba(0, 0, 0, .5);
        padding: 10px;
        color: #fff;
    }

</style>

<script>
    import common from '../../static/common/common.js'
    export default{
        data(){
            return {
            imgCategory:[],
            imgListInfo:[]                
            }
        },
        created(){
            this.getImgCategory()
            this.getImgList(0)
        },
        methods:{
            getImgCategory(){
                const url = common.baseUrl+'api/getimgcategory'
                this.$http.get(url).then(res=>{
                    console.log(res.body);
                    this.imgCategory = res.body.message
                })
            },
            getImgList(id){
                const url = common.baseUrl+'api/getimages/'+id
                this.$http.get(url).then(res=>{
                    this.imgListInfo = res.body.message
                })
            }

        }
    }
</script>